//引入express模块
const express=require('express');
//引入连接池模块
const pool=require('../pool.js');
//console.log(pool);
//创建路由器对象
const r=express.Router();
//查找轮播图接口(get/slideshow)
//接口地址：http://127.0.0.1:3000/v1/slideshows/slideshow
//请求方式：get
r.get('/slideshow',(req,res,next)=>{
	//获取路由传递的参数
	var obj=req.params;
	console.log(obj);
	//执行sql命令
	pool.query('select * from slideshow ',(err,result)=>{
		if(err){
			next(err);
			return;
		}
		console.log(result);
		if(result.length===0){
			res.send({code:501,msg:'查找失败'});
		}else{
			res.send({code:200,msg:'查找成功',data:result});
		}
	});
});

module.exports=r;
